home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / vectors / qtvectors / qtvectors.c < prev    next >
Encoding:
Text File  |  2000-09-28  |  19.8 KB  |  517 lines

  1. //////////
  2. //
  3. //    File:        QTVectors.c
  4. //
  5. //    Contains:    QuickTime vector drawing support for QuickTime movies.
  6. //
  7. //    Written by:    Tim Monroe
  8. //                Based largely on VectorSample code by Tom Dowdy(?).
  9. //
  10. //    Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //    Change History (most recent first):
  13. //
  14. //       <8>         09/30/98    rtm        tweaked call to AddMovieResource to create single-fork movies
  15. //       <7>         03/12/98    rtm        removed NewHandleClear calls before CurveCreateVectorStream and CurveNewPath
  16. //                                    (which allocate the handles themselves)
  17. //       <6>         01/06/98    rtm        minor clean-up
  18. //       <5>         11/14/97    rtm        removed endian macros on parameters to CurveAddAtomToVectorStream;
  19. //                                    Windows works better now, but still not perfect
  20. //                                    (e.g., CurveInsertPointIntoPath seems to ignore ptIsOnPath parameter)
  21. //       <4>         11/13/97    rtm        added USE_CURVE_INSERT_POINT_INTO_PATH symbol for easier testing
  22. //       <3>         11/05/97    rtm        got raw data stream working on Windows; the Curve Utilities seem broken on Windows
  23. //       <2>         11/04/97    rtm        added constants; added comments parsing atoms; reworked using Curve Utilities
  24. //       <1>         11/03/97    rtm        first file
  25. //       
  26. //////////
  27.  
  28. #include <FixMath.h>
  29. #include <Fonts.h>
  30. #include <GXTypes.h>
  31. #include <ImageCodec.h>
  32. #include <ImageCompression.h>
  33. #include <MacTypes.h>
  34. #include <MacWindows.h>
  35. #include <Movies.h>
  36. #include <QuickDraw.h>
  37. #include <QuickTimeComponents.h>
  38. #include <StandardFile.h>
  39. #include <Sound.h>
  40.  
  41. #include "QTVectors.h"
  42.  
  43. // the following compiler symbol is used to select whether, when using the Curve Utilities,
  44. // we call CurveInsertPointIntoPath or CurveAddAtomToVectorStream
  45. #define USE_CURVE_INSERT_POINT_INTO_PATH        1
  46.  
  47.  
  48. //////////
  49. //
  50. // QTVectors_CreateVectorMovie
  51. // Create a movie containing some QuickTime vector shapes.
  52. //
  53. // Currently we support two ways of building the vector data:
  54. //    * kUseRawDataStream: build the vector data using a stream of raw hard-coded data
  55. //    * kUseCurveUtilities: build the vector data using the Curve Utilities API
  56. //    
  57. //////////
  58.  
  59. void QTVectors_CreateVectorMovie (UInt32 theBuildAtomMethod)
  60. {
  61.     Handle                        myHandle = NULL;
  62.     ImageDescriptionHandle        mySampleDesc = NULL;
  63.     short                        myResRefNum = 0;
  64.     short                        myResID = movieInDataForkResID;
  65.     Movie                        myMovie = NULL;
  66.     Track                        myTrack;
  67.     Media                        myMedia;
  68.     StandardFileReply            myReply;
  69.     ComponentInstance            myComponent;
  70.     ComponentResult                myResult;
  71.     long                        myFlags = createMovieFileDeleteCurFile | createMovieFileDontCreateResFile;
  72.     OSErr                        myErr = noErr;
  73.     
  74.     // METHOD ONE: use a raw data stream
  75.     
  76.     if (theBuildAtomMethod == kUseRawDataStream) {
  77.     
  78.         // kUseRawDataStream: build the vector data using a stream of hard-coded raw data
  79.         // NOTE: the data in the stream *must* be big-endian, since it's stored in a QuickTime atom container.
  80.  
  81.         long                    myPath[] = {    
  82.             
  83.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)), EndianU32_NtoB(kCurveAntialiasControlAtom),
  84.             EndianU32_NtoB(kCurveAntialiasOn),
  85.  
  86.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)), EndianU32_NtoB(kCurveFillTypeAtom),
  87.             EndianU32_NtoB(gxEvenOddFill),
  88.  
  89.         // a big white enclosing rectangle (600 x 600)
  90.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(ARGBColor)), EndianU32_NtoB(kCurveARGBColorAtom),
  91.             EndianU32_NtoB(0xffffffff),    // alpha, red
  92.             EndianU32_NtoB(0xffffffff),    // green, blue
  93.                                         // it's white!
  94.  
  95.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)*11), EndianU32_NtoB(kCurvePathAtom),
  96.             EndianU32_NtoB(1),            // one contour in path
  97.             EndianU32_NtoB(4),            // four points in path
  98.             EndianU32_NtoB(0x00000000),    // all points are on the curve: it's a rectangle! 
  99.             EndianU32_NtoB(0x00000000), EndianU32_NtoB(0x00000000),     // top left
  100.             EndianU32_NtoB(0x02580000), EndianU32_NtoB(0x00000000),        // top right
  101.             EndianU32_NtoB(0x02580000), EndianU32_NtoB(0x02580000),        // bottom right 
  102.             EndianU32_NtoB(0x00000000), EndianU32_NtoB(0x02580000),        // bottom left
  103.  
  104.         // a black rounded square, centered at 150,150
  105.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(ARGBColor)), EndianU32_NtoB(kCurveARGBColorAtom),
  106.             EndianU32_NtoB(0x00000000),    // alpha, red
  107.             EndianU32_NtoB(0x00000000),    // green, blue
  108.                                         // it's black!
  109.  
  110.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)*11), EndianU32_NtoB(kCurvePathAtom),
  111.             EndianU32_NtoB(1),            // one contour in path
  112.             EndianU32_NtoB(4),            // four points in path
  113.             EndianU32_NtoB(0xffffffff), // all points are off the curve: it's a rounded square! 
  114.             EndianU32_NtoB(0x00640000), EndianU32_NtoB(0x00640000),
  115.             EndianU32_NtoB(0x00C80000), EndianU32_NtoB(0x00640000),
  116.             EndianU32_NtoB(0x00C80000), EndianU32_NtoB(0x00C80000), 
  117.             EndianU32_NtoB(0x00640000), EndianU32_NtoB(0x00C80000),
  118.  
  119.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)), EndianU32_NtoB(kCurveFillTypeAtom),
  120.             EndianU32_NtoB(gxEvenOddFill),
  121.  
  122.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)), EndianU32_NtoB(kCurvePenThicknessAtom),
  123.             EndianU32_NtoB(0x100000),
  124.                                             
  125.         // enable linear gradient for all following atoms
  126.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)), EndianU32_NtoB(kCurveGradientTypeAtom),
  127.             EndianU32_NtoB(kLinearGradient),
  128.         
  129.         // define the gradient: red -> green -> red -> blue                                    
  130.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(GradientColorRecord)*4), EndianU32_NtoB(kCurveGradientRecordAtom),
  131.                                         
  132.             EndianU32_NtoB(0xffffffff),    // gradient color record 1:
  133.             EndianU32_NtoB(0x00000000),    // red
  134.             EndianU32_NtoB(0x00000000),    // beginning of gradient
  135.                                         
  136.             EndianU32_NtoB(0x77770000),    // gradient color record 2:
  137.             EndianU32_NtoB(0xffff0000),    // green
  138.             EndianU32_NtoB(0x00004000),
  139.                                         
  140.             EndianU32_NtoB(0x3333ffff),    // gradient color record 3:
  141.             EndianU32_NtoB(0x00000000),    // red
  142.             EndianU32_NtoB(0x0000C000),
  143.                                         
  144.             EndianU32_NtoB(0xffff0000),    // gradient color record 4:
  145.             EndianU32_NtoB(0x0000ffff),    // blue
  146.             EndianU32_NtoB(0x00010000),    // end of gradient
  147.  
  148.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)), EndianU32_NtoB(kCurveGradientAngleAtom),
  149.             EndianU32_NtoB(0x00450000),    // gradient at 45˚ angle
  150.         
  151.         // a green rectangle, centered at 40,40, painted with a linear gradient                                    
  152.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(ARGBColor)), EndianU32_NtoB(kCurveARGBColorAtom),
  153.             EndianU32_NtoB(0x00000000),    // alpha, red
  154.             EndianU32_NtoB(0xffff0000),    // green, blue
  155.                                         // it's green!
  156.  
  157.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)*11), EndianU32_NtoB(kCurvePathAtom),
  158.             EndianU32_NtoB(1),            // one contour in path
  159.             EndianU32_NtoB(4),            // four points in path
  160.             EndianU32_NtoB(0x00000000),    // all points are on the curve: it's a rectangle! 
  161.             EndianU32_NtoB(0x00100000), EndianU32_NtoB(0x00100000),
  162.             EndianU32_NtoB(0x00400000), EndianU32_NtoB(0x00100000),
  163.             EndianU32_NtoB(0x00400000), EndianU32_NtoB(0x00400000),
  164.             EndianU32_NtoB(0x00100000), EndianU32_NtoB(0x00400000),
  165.  
  166.         // disable gradient for all following atoms (since no atom data)
  167.         EndianU32_NtoB(kSizeOfSizeAndTagFields), EndianU32_NtoB(kCurveGradientRecordAtom),
  168.                                     
  169.         // a red rounded square, centered at 50,50
  170.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(ARGBColor)), EndianU32_NtoB(kCurveARGBColorAtom),
  171.             EndianU32_NtoB(0x3333ffff),    // alpha, red
  172.             EndianU32_NtoB(0x00000000),    // green, blue
  173.                                         // it's red!
  174.  
  175.         EndianU32_NtoB(kSizeOfSizeAndTagFields + sizeof(long)*11), EndianU32_NtoB(kCurvePathAtom),
  176.             EndianU32_NtoB(1L),            // one contour in path
  177.             EndianU32_NtoB(4L),            // four points in path
  178.             EndianU32_NtoB(0xffffffff), // all points are off the curve: it's a rounded square! 
  179.             EndianU32_NtoB(0x001e0000), EndianU32_NtoB(0x001e0000),
  180.             EndianU32_NtoB(0x00460000), EndianU32_NtoB(0x001e0000),
  181.             EndianU32_NtoB(0x00460000), EndianU32_NtoB(0x00460000),
  182.             EndianU32_NtoB(0x001e0000), EndianU32_NtoB(0x00460000),
  183.  
  184.         EndianU32_NtoB(kSizeOfZeroAtomHeader), EndianU32_NtoB(kCurveEndAtom),
  185.     };
  186.             
  187.         myHandle = NewHandle(sizeof(myPath));
  188.         if (myHandle == NULL)
  189.             goto bail;
  190.             
  191.         BlockMove(myPath, *myHandle, sizeof(myPath));
  192.     
  193.     }    // end of kUseRawDataStream
  194.  
  195.     
  196.     // METHOD TWO: use the Curve Utilities API
  197.     
  198.     if (theBuildAtomMethod == kUseCurveUtilities) {
  199.     
  200.         // kUseCurveUtilities: build the vector data using the Curve Utilities API        
  201.         Handle                        myPath;
  202.         gxPoint                        myPoint;
  203.         long                        myAtomData[14];
  204.         ARGBColor                    myColor;
  205.         GradientColorRecord            myGradients[4];
  206.     
  207.         // open the vector codec; we'll need it for some subsequent calls
  208.         myComponent = OpenDefaultComponent(decompressorComponentType, kVectorCodecType);
  209.         if (myComponent == NULL)
  210.             goto bail;
  211.  
  212.         // create a new, empty vector data stream
  213.         myResult = CurveCreateVectorStream(myComponent, &myHandle);
  214.         if (myResult != noErr)
  215.             goto bail;
  216.         
  217.         // now start adding atoms holding the vector data
  218.         
  219.         // set antialiasing on
  220.         myAtomData[0] = EndianU32_NtoB(kCurveAntialiasOn);
  221.         CurveAddAtomToVectorStream(myComponent, kCurveAntialiasControlAtom, sizeof(long), myAtomData, myHandle);
  222.  
  223.         // set fill type
  224.         myAtomData[0] = EndianU32_NtoB(gxEvenOddFill);
  225.         CurveAddAtomToVectorStream(myComponent, kCurveFillTypeAtom, sizeof(long), myAtomData, myHandle);
  226.  
  227.         // a big white enclosing rectangle (600 x 600)
  228.         myColor.alpha = EndianU16_NtoB(0xffff);
  229.         myColor.red = EndianU16_NtoB(0xffff);
  230.         myColor.green = EndianU16_NtoB(0xffff);
  231.         myColor.blue = EndianU16_NtoB(0xffff);
  232.         CurveAddAtomToVectorStream(myComponent, kCurveARGBColorAtom, sizeof(ARGBColor), &myColor, myHandle);
  233.  
  234. #if USE_CURVE_INSERT_POINT_INTO_PATH
  235.         // create a new, empty path
  236.         CurveNewPath(myComponent, &myPath);
  237.  
  238.         myPoint.x = 0x00000000;
  239.         myPoint.y = 0x00000000;
  240.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 0, true);
  241.         
  242.         myPoint.x = 0x02580000;
  243.         myPoint.y = 0x00000000;
  244.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 1, true);
  245.         
  246.         myPoint.x = 0x02580000;
  247.         myPoint.y = 0x02580000;
  248.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 2, true);
  249.         
  250.         myPoint.x = 0x00000000;
  251.         myPoint.y = 0x02580000;
  252.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 3, true);
  253.  
  254.         // add the 'path' atom to the vector data stream
  255.         CurveAddPathAtomToVectorStream(myComponent, myPath, myHandle);
  256.         DisposeHandle(myPath);
  257. #else
  258.         myAtomData[0] = EndianU32_NtoB(1L);
  259.         myAtomData[1] = EndianU32_NtoB(4L);
  260.         myAtomData[2] = EndianU32_NtoB(0x00000000);
  261.         myAtomData[3] = EndianU32_NtoB(0x00000000);
  262.         myAtomData[4] = EndianU32_NtoB(0x00000000);
  263.         myAtomData[5] = EndianU32_NtoB(0x02580000);
  264.         myAtomData[6] = EndianU32_NtoB(0x00000000);
  265.         myAtomData[7] = EndianU32_NtoB(0x02580000);
  266.         myAtomData[8] = EndianU32_NtoB(0x02580000);
  267.         myAtomData[9] = EndianU32_NtoB(0x00000000);
  268.         myAtomData[10] = EndianU32_NtoB(0x02580000);
  269.         CurveAddAtomToVectorStream(myComponent, kCurvePathAtom, sizeof(long)*11, myAtomData, myHandle);
  270. #endif
  271.         
  272.         // a black rounded square, centered at 150,150
  273.         myColor.alpha = EndianU16_NtoB(0x0000);
  274.         myColor.red = EndianU16_NtoB(0x0000);
  275.         myColor.green = EndianU16_NtoB(0x0000);
  276.         myColor.blue = EndianU16_NtoB(0x0000);
  277.         CurveAddAtomToVectorStream(myComponent, kCurveARGBColorAtom, sizeof(ARGBColor), &myColor, myHandle);
  278.  
  279. #if USE_CURVE_INSERT_POINT_INTO_PATH
  280.         // create a new, empty path
  281.         CurveNewPath(myComponent, &myPath);
  282.  
  283.         myPoint.x = 0x00640000;
  284.         myPoint.y = 0x00640000;
  285.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 0, false);
  286.         
  287.         myPoint.x = 0x00C80000;
  288.         myPoint.y = 0x00640000;
  289.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 1, false);
  290.         
  291.         myPoint.x = 0x00C80000;
  292.         myPoint.y = 0x00C80000;
  293.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 2, false);
  294.         
  295.         myPoint.x = 0x00640000;
  296.         myPoint.y = 0x00C80000;
  297.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 3, false);
  298.  
  299.         // add the 'path' atom to the vector data stream
  300.         CurveAddPathAtomToVectorStream(myComponent, myPath, myHandle);
  301.         DisposeHandle(myPath);
  302. #else
  303.         myAtomData[0] = EndianU32_NtoB(1L);
  304.         myAtomData[1] = EndianU32_NtoB(4L);
  305.         myAtomData[2] = EndianU32_NtoB(0xffffffff);
  306.         myAtomData[3] = EndianU32_NtoB(0x00640000);
  307.         myAtomData[4] = EndianU32_NtoB(0x00640000);
  308.         myAtomData[5] = EndianU32_NtoB(0x00C80000);
  309.         myAtomData[6] = EndianU32_NtoB(0x00640000);
  310.         myAtomData[7] = EndianU32_NtoB(0x00C80000);
  311.         myAtomData[8] = EndianU32_NtoB(0x00C80000);
  312.         myAtomData[9] = EndianU32_NtoB(0x00640000);
  313.         myAtomData[10] = EndianU32_NtoB(0x00C80000);
  314.         CurveAddAtomToVectorStream(myComponent, kCurvePathAtom, sizeof(long)*11, myAtomData, myHandle);
  315. #endif
  316.  
  317.         // set fill type
  318.         myAtomData[0] = EndianU32_NtoB(gxEvenOddFill);
  319.         CurveAddAtomToVectorStream(myComponent, kCurveFillTypeAtom, sizeof(long), myAtomData, myHandle);
  320.  
  321.         // set pen thickness
  322.         myAtomData[0] = EndianU32_NtoB(0x100000);
  323.         CurveAddAtomToVectorStream(myComponent, kCurvePenThicknessAtom, sizeof(long), myAtomData, myHandle);
  324.  
  325.         // enable linear gradient for all following atoms
  326.         myAtomData[0] = EndianU32_NtoB(kLinearGradient);
  327.         CurveAddAtomToVectorStream(myComponent, kCurveGradientTypeAtom, sizeof(long), myAtomData, myHandle);
  328.  
  329.         // define the gradient: red -> green -> red -> blue                                    
  330.         myGradients[0].thisColor.alpha = EndianU16_NtoB(0xffff);
  331.         myGradients[0].thisColor.red = EndianU16_NtoB(0xffff);
  332.         myGradients[0].thisColor.green = EndianU16_NtoB(0x0000);
  333.         myGradients[0].thisColor.blue = EndianU16_NtoB(0x0000);
  334.         myGradients[0].endingPercentage = EndianU32_NtoB(0x00000000);
  335.         myGradients[1].thisColor.alpha = EndianU16_NtoB(0x7777);
  336.         myGradients[1].thisColor.red = EndianU16_NtoB(0x0000);
  337.         myGradients[1].thisColor.green = EndianU16_NtoB(0xffff);
  338.         myGradients[1].thisColor.blue = EndianU16_NtoB(0x0000);
  339.         myGradients[1].endingPercentage = EndianU32_NtoB(0x00004000);
  340.         myGradients[2].thisColor.alpha = EndianU16_NtoB(0x3333);
  341.         myGradients[2].thisColor.red = EndianU16_NtoB(0xffff);
  342.         myGradients[2].thisColor.green = EndianU16_NtoB(0x0000);
  343.         myGradients[2].thisColor.blue = EndianU16_NtoB(0x0000);
  344.         myGradients[2].endingPercentage = EndianU32_NtoB(0x0000C000);
  345.         myGradients[3].thisColor.alpha = EndianU16_NtoB(0xffff);
  346.         myGradients[3].thisColor.red = EndianU16_NtoB(0x0000);
  347.         myGradients[3].thisColor.green = EndianU16_NtoB(0x0000);
  348.         myGradients[3].thisColor.blue = EndianU16_NtoB(0xffff);
  349.         myGradients[3].endingPercentage = EndianU32_NtoB(0x00010000);
  350.         CurveAddAtomToVectorStream(myComponent, kCurveGradientRecordAtom, sizeof(GradientColorRecord)*4, myGradients, myHandle);
  351.  
  352.         // set gradient angle
  353.         myAtomData[0] = EndianU32_NtoB(0x00450000);
  354.         CurveAddAtomToVectorStream(myComponent, kCurveGradientAngleAtom, sizeof(long), myAtomData, myHandle);
  355.  
  356.         // a green rectangle, centered at 40,40, painted with a linear gradient                                    
  357.         myColor.alpha = EndianU16_NtoB(0x0000);
  358.         myColor.red = EndianU16_NtoB(0x0000);
  359.         myColor.green = EndianU16_NtoB(0xffff);
  360.         myColor.blue = EndianU16_NtoB(0x0000);
  361.         CurveAddAtomToVectorStream(myComponent, kCurveARGBColorAtom, sizeof(ARGBColor), &myColor, myHandle);
  362.  
  363. #if USE_CURVE_INSERT_POINT_INTO_PATH
  364.         // create a new, empty path
  365.         CurveNewPath(myComponent, &myPath);
  366.  
  367.         myPoint.x = 0x00100000;
  368.         myPoint.y = 0x00100000;
  369.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 0, true);
  370.         
  371.         myPoint.x = 0x00400000;
  372.         myPoint.y = 0x00100000;
  373.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 1, true);
  374.         
  375.         myPoint.x = 0x00400000;
  376.         myPoint.y = 0x00400000;
  377.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 2, true);
  378.         
  379.         myPoint.x = 0x00100000;
  380.         myPoint.y = 0x00400000;
  381.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 3, true);
  382.  
  383.         // add the 'path' atom to the vector data stream
  384.         CurveAddPathAtomToVectorStream(myComponent, myPath, myHandle);
  385.         DisposeHandle(myPath);
  386. #else
  387.         myAtomData[0] = EndianU32_NtoB(1L);
  388.         myAtomData[1] = EndianU32_NtoB(4L);
  389.         myAtomData[2] = EndianU32_NtoB(0x00000000);
  390.         myAtomData[3] = EndianU32_NtoB(0x00100000);
  391.         myAtomData[4] = EndianU32_NtoB(0x00100000);
  392.         myAtomData[5] = EndianU32_NtoB(0x00400000);
  393.         myAtomData[6] = EndianU32_NtoB(0x00100000);
  394.         myAtomData[7] = EndianU32_NtoB(0x00400000);
  395.         myAtomData[8] = EndianU32_NtoB(0x00400000);
  396.         myAtomData[9] = EndianU32_NtoB(0x00100000);
  397.         myAtomData[10] = EndianU32_NtoB(0x00400000);
  398.         CurveAddAtomToVectorStream(myComponent, kCurvePathAtom, sizeof(long)*11, myAtomData, myHandle);
  399. #endif
  400.  
  401.         // disable gradient for all following atoms (since no atom data)
  402.         CurveAddAtomToVectorStream(myComponent, kCurveGradientTypeAtom, 0, NULL, myHandle);
  403.         
  404.         // a red rounded square, centered at 50,50
  405.         myColor.alpha = EndianU16_NtoB(0x3333);
  406.         myColor.red = EndianU16_NtoB(0xffff);
  407.         myColor.green = EndianU16_NtoB(0x0000);
  408.         myColor.blue = EndianU16_NtoB(0x0000);
  409.         CurveAddAtomToVectorStream(myComponent, kCurveARGBColorAtom, sizeof(ARGBColor), &myColor, myHandle);
  410.  
  411. #if USE_CURVE_INSERT_POINT_INTO_PATH
  412.         // create a new, empty path
  413.         CurveNewPath(myComponent, &myPath);
  414.  
  415.         myPoint.x = 0x001e0000;
  416.         myPoint.y = 0x001e0000;
  417.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 0, false);
  418.         
  419.         myPoint.x = 0x00460000;
  420.         myPoint.y = 0x001e0000;
  421.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 1, false);
  422.         
  423.         myPoint.x = 0x00460000;
  424.         myPoint.y = 0x00460000;
  425.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 2, false);
  426.         
  427.         myPoint.x = 0x001e0000;
  428.         myPoint.y = 0x00460000;
  429.         CurveInsertPointIntoPath(myComponent, &myPoint, myPath, 0, 3, false);
  430.  
  431.         // add the 'path' atom to the vector data stream
  432.         CurveAddPathAtomToVectorStream(myComponent, myPath, myHandle);
  433.         DisposeHandle(myPath);
  434. #else
  435.         myAtomData[0] = EndianU32_NtoB(1L);
  436.         myAtomData[1] = EndianU32_NtoB(4L);
  437.         myAtomData[2] = EndianU32_NtoB(0xffffffff);
  438.         myAtomData[3] = EndianU32_NtoB(0x001e0000);
  439.         myAtomData[4] = EndianU32_NtoB(0x001e0000);
  440.         myAtomData[5] = EndianU32_NtoB(0x00460000);
  441.         myAtomData[6] = EndianU32_NtoB(0x001e0000);
  442.         myAtomData[7] = EndianU32_NtoB(0x00460000);
  443.         myAtomData[8] = EndianU32_NtoB(0x00460000);
  444.         myAtomData[9] = EndianU32_NtoB(0x001e0000);
  445.         myAtomData[10] = EndianU32_NtoB(0x00460000);
  446.         CurveAddAtomToVectorStream(myComponent, kCurvePathAtom, sizeof(long)*11, myAtomData, myHandle);
  447. #endif
  448.  
  449.         // add the 'zero' atom to the vector data stream
  450.         CurveAddZeroAtomToVectorStream(myComponent, myHandle);
  451.         
  452.     }    // end of kUseCurveUtilities
  453.     
  454.     // create the image description
  455.     mySampleDesc = (ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription));
  456.     if (mySampleDesc == NULL)
  457.         goto bail;
  458.     
  459.     // fill in the fields of the image description
  460.     (**mySampleDesc).idSize = sizeof(ImageDescription);
  461.     (**mySampleDesc).cType = kVectorCodecType;
  462.     (**mySampleDesc).vendor = kAppleManufacturer;
  463.     (**mySampleDesc).temporalQuality = codecNormalQuality;
  464.     (**mySampleDesc).spatialQuality = codecNormalQuality;
  465.     (**mySampleDesc).width = 300;
  466.     (**mySampleDesc).height = 300;
  467.     (**mySampleDesc).hRes = 72L << 16;
  468.     (**mySampleDesc).vRes = 72L << 16;
  469.     (**mySampleDesc).dataSize = 0L;
  470.     (**mySampleDesc).frameCount = 1;
  471.     (**mySampleDesc).depth = 0;
  472.     (**mySampleDesc).clutID = -1;
  473.         
  474.     // prompt user for new file name
  475.     StandardPutFile("\pNew Curve Movie:", "\pshapes.mov", &myReply);
  476.     if (!myReply.sfGood)
  477.         goto bail;
  478.     
  479.     // create a movie file for the destination movie
  480.     myErr = CreateMovieFile(&myReply.sfFile, FOUR_CHAR_CODE('TVOD'), smCurrentScript, myFlags, &myResRefNum, &myMovie);
  481.     if (myErr != noErr)
  482.         goto bail;
  483.     
  484.     // create the vector track and media
  485.     myTrack = NewMovieTrack(myMovie, FixDiv(300, 1), FixDiv(300, 1), kNoVolume);
  486.     myMedia = NewTrackMedia(myTrack, VideoMediaType, 600, NULL, 0);
  487.     
  488.     // create the vector media sample
  489.     BeginMediaEdits(myMedia);
  490.         
  491.     myErr = AddMediaSample(myMedia, myHandle, 0, GetHandleSize(myHandle), 600, (SampleDescriptionHandle)mySampleDesc, 1, 0, NULL);
  492.     if (myErr != noErr)
  493.         goto bail;
  494.         
  495.     EndMediaEdits(myMedia);
  496.     
  497.     // add the media to the track
  498.     InsertMediaIntoTrack(myTrack, 0, 0, GetMediaDuration(myMedia), fixed1);
  499.     AddMovieResource(myMovie, myResRefNum, &myResID, NULL);
  500.  
  501. bail:
  502.     if (mySampleDesc != NULL)
  503.         DisposeHandle((Handle)mySampleDesc);
  504.     
  505.     if (myResRefNum != 0)
  506.         CloseMovieFile(myResRefNum);
  507.  
  508.     if (myHandle != NULL)
  509.         DisposeHandle(myHandle);
  510.  
  511.     if (myMovie != NULL)
  512.         DisposeMovie(myMovie);
  513.  
  514.     if (myComponent != NULL)
  515.         CloseComponent(myComponent);
  516. }
  517.